-
Notifications
You must be signed in to change notification settings - Fork 7
cgosqlite: add optional hook to verify ColumnBlob bytes are unmodified #124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
If a hook is given, then a `runtime.AddCleanup` is registered for the []byte returned from ColumnBlob that verifies whether it's been modified. If so, the hook function is called with the corresponding query. Also, add tests to confirm that this works as expected. Updates tailscale/corp#35671 Signed-off-by: Andrew Dunham <[email protected]>
|
Not sure we want to do this, but @raggi mentioned this in Slack and I figured it'd be interesting to try out 😃 I'm going to run this commit against the full corp testsuite and see what happens. |
raggi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I mean I'm not sure if we have a strong reason to believe this is where we need to dig but if we did this a sampling way (some portion of queries) it might give some signal.
| // TODO: We use uintptr instead of []byte to avoid keeping the slice alive | ||
| // (which would prevent the cleanup from running); is that right? | ||
| type blobCheckArg struct { | ||
| original []byte // copy of original data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or instead of this bytes.Clone, maybe store a https://pkg.go.dev/hash/fnv#New64a hash of the original data?
| // can ensure they've run. | ||
| checkRun := make(chan struct{}, 10_000) // high enough to never block | ||
| blobCheckHook = func() { | ||
| checkRun <- struct{}{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
select {
case checkRun <- struct{}{}:
default:
panic("checkRun unexpectedly full")
}
If a hook is given, then a
runtime.AddCleanupis registered for the []byte returned from ColumnBlob that verifies whether it's been modified. If so, the hook function is called with the corresponding query. Also, add tests to confirm that this works as expected.Updates tailscale/corp#35671